using System.Collections.Generic;
using System.Windows.Media;
using System.Windows.Shapes;

namespace Vec
{
	public class WPFPath
	{
		public List<PF> pts = new List<PF>();
		private Path path = new Path();

		//List<RectangularShape> sps = new List<>();
		public void lineTo(float x, float y)
		{
			pts.Add(new PF(x, y, false));
		}

		public void reset()
		{
			pts.Clear();
			//sps.clear();
		}

		public bool isEmpty()
		{
			return pts.Count == 0;
		}

		public void addRect(RectF rf, Direction dir)
		{
			//sps.add(new Rectangle2D.Double(rf.left, rf.top, rf.width(), rf.height()));
		}

		public void addCircle(int x, int y, float r, Direction dir)
		{
			//sps.add(new Ellipse2D.Double(x - r, y - r, 2 * r, 2 * r));
		}

		public void addOval(RectF rf, Direction dir)
		{
			//sps.add(new Ellipse2D.Double(rf.left, rf.top, rf.width(), rf.height()));
		}

		public void moveTo(float x, float y)
		{
			pts.Add(new PF(x, y, true));
		}

		public void arcTo(RectF rf, float start, float v, bool b)
		{
			//sps.add(new Arc2D.Double(rf.left, rf.top, rf.width(), rf.height(), -start, -v, b ? Arc2D.PIE : Arc2D.OPEN));
		}

		public void close()
		{
			/*if (pts.size() == 0) return;
			PF lastStart = null;
			//System.out.println("close");
			for (int i = 0; i < pts.size(); i++)
			{
				PF p = pts.get(i);
				if (p.start)
				{
					if (lastStart == null) lastStart = p;
					else
					{
						pts.add(i - 1, new PF(lastStart.x, lastStart.y, false));
						lastStart = p;
						i++;
					}
				}
			}
			if (lastStart != null)
			{
				pts.add(new PF(lastStart.x, lastStart.y, false));
			}*/
		}

		public void addRoundRect(RectF rf, float r1, float r2, Direction dir)
		{
			//sps.add(new RoundRectangle2D.Double(rf.left, rf.top, rf.width(), rf.height(), r1, r2));
		}

		public void transform(Matrix m, WPFPath p2)
		{
			/*for (RectangularShape rs: sps)
			{
				RectangularShape r2 = (RectangularShape)rs.clone();
				double sx = m.getScaleX();
				double sy = m.getScaleY();
				r2.setFrame(r2.getX() * sx, r2.getY() * sy, r2.getWidth() * sx, r2.getHeight() * sy);
				p2.sps.add(r2);
			}
			for (PF pf: pts)
			{
				PF pf2 = new PF(pf.x, pf.y, pf.start);
				double sx = m.getScaleX();
				double sy = m.getScaleY();
				pf2.set((float)(pf2.x * sx), (float)(pf2.y * sy));
				p2.pts.add(pf2);
			}*/
			//p2.pos.addAll(pos);
		}

		public class PF : PointF
		{
			public bool start = false;

			public PF(float x, float y, bool st) : base(x, y)
			{
				this.start = st;
			}

			public string toString()
			{
				return x + "," + y + "," + start;
			}
		}

		public enum Direction
		{
			CW, CCW
		}
	}
}